﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Text;

namespace CRM.BLL
{
    public class PartsB
    {
        #region Parts
        /// <summary>
        /// 获取Parts信息
        /// </summary>
        public DataTable GetParts(ref CRM.MODEL.GetParts stu)
        {
            CRM.DAL.PartsD obj = new CRM.DAL.PartsD();
            DataTable dt = obj.ExecuteGetParts(ref stu);
            obj.Dispose();
            return dt;
        }

        /// <summary>
        /// 编辑Parts信息
        /// </summary>
        public int EditParts(ref CRM.MODEL.EditParts stu)
        {
            CRM.DAL.PartsD obj = new CRM.DAL.PartsD();
            int effectRow = obj.ExecuteEditParts(ref stu);
            obj.Dispose();
            return effectRow;
        }
        #endregion

        public string GetRandomNO(out int maxID)
        {
            maxID = 0;
            var stu = new MODEL.GetParts();
            var dt = GetParts(ref stu);
            if (dt != null && dt.Rows.Count > 0)
            {
                maxID = int.Parse(dt.Rows[0]["ID"].ToString());
                return
                    (maxID + 1).ToString(CultureInfo.InvariantCulture)
                        .PadLeft(6, '0');
            }
            return "000001";

        }
    }
}
